// 续签合同
<template>
    <div class="contractRenew">
        <div class="title">续签记录</div>
        <el-table :data="tableData" style="width: 100%"
                  :row-style="tableRowStyle"  >
            <el-table-column prop="createName" label="操作人" width="300" align="center"/>
            <el-table-column prop="signDate" label="合同签订日期" width="300" align="center"/>
            <el-table-column prop="signType" label="签订方式" width="300" align="center">
                <template slot-scope="scope">{{scope.row.signType | dict('rent_signing_method')}}</template>
            </el-table-column>
            <el-table-column prop="contractCode" width="300" label="合同编码" align="center"/>
            <el-table-column width="100" label="操作" align="center">
                <template slot-scope="scope">
                    <el-button type="text" v-if="scope.row.rentContractId!=rentContractId" @click="view(scope.row)">查看</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    import {getRenewList} from '../../api/rent-contract.js'

    export default {
        name: 'contractRenew',
        data() {
            return {
                rentContractId: "",
                tableData: [],
            }
        },

        mounted: function () {
            //this.loadRenewList();
        },

        methods: {
            //加载列表
            loadRenewList(contractId) {
                //alert("11");
                let rentContractId = contractId;//this.$route.query.id;
                this.rentContractId = rentContractId;
                //alert(rentContractId);
                let category = 1
                getRenewList(rentContractId, category)
                    .then(response => {
                            //alert(JSON.parse(response.data));
                            if (response.data.code == 0) {
                                this.tableData = response.data.data;
                            } else {
                                this.$alert("加载变更记录服务端服务错误" + response.code);
                            }
                        }
                    )
            },

            view(row) {
                //alert(JSON.stringify(row));
                //link("/wy-rent/contract/view?id=" + row.rentContractId);
                //this.$router.push({path:"/"});
                //this.$emit('init',row.rentContractId)
                //this.$router.replace({path: "/wy-rent/contract/view?id=" + row.rentContractId});

                //改成弹出框了，刷新父级数据
                //console.log(this.$parent.$parent.$parent.$parent);
                this.$parent.$parent.$parent.$parent.show(row.rentContractId);
                this.$parent.$parent.$parent.$parent.activeName="first";
                //this.reload();


            },
            tableRowStyle(scope){
                if (scope.row.rentContractId == this.rentContractId) {
                    //alert("1");
                    return { backgroundColor: "yellow"}
                }
            }
        }

    }
</script>

<style lang="scss" scoped>
    .contractRenew {
        .title {
            font-size: 16px;
            font-weight: bold;
            margin: 10px 0 20px;
            color: #333;
        }

        /deep/ .el-table {
            .el-table__header {
                border-color: #dee2e6;
            }

            thead th {
                background-color: #FAFAFA;
                color: #333;
            }

            td {
                padding: 10px 0;
            }
        }
    }


</style>
